<!DOCTYPE html>
<html lang=“en”>
<head>
<meta chaset="UTF-8">
<title>生命周期</title>
<script src='./vue.js'></script>
</head>
<body>
<div id="app"></div>
<script>
//生命周期函数是vue实例在某个时间点会自动执行的函数，直接置于实例上，不放在methods里
var vm=new Vue({
el:"#app",
template:"<div>{{test}}</div>",
data:{
test:"hello world",
},
beforeCreate:function(){//实例初始化前
console.log("beforecreate");},
created:function(){//已初始化
console.log("created");},
beforeMount:function(){//页面挂载之前
console.log(this.$el);
console.log("beforemount");},
mounted:function(){//页面挂载完成
console.log(this.$el);
console.log("mounted");},
/*beforedestroy:function(){/调用vm.$destory()事件后才会执行
console.log("beforedestroy");},
destroyed:function(){
console.log("destroyed");},*/
beforeUpdate:function(){//数据变化前
console.log("beforeupdate");},
updated:function(){//数据变化后
console.log("updated");},
})

</script>
</body>